<?php
namespace app\controller\api\v1\housing;

use app\Request;
use app\model\v1\housing\HousingIndustry as HousingIndustrymdoel;
class HousingIndustry{  //房产业态



	public function HousingIndustry_list($id = false)
	{
		$data = $this->getTree();

		return app('json')->success($data);
	}
	// 递归处理寻找所有下级数据 `
	public function getTree( $id=0)
	{
		$HousingIndustrymdoel = new HousingIndustrymdoel();

		$result = [];
//查找当前id的所有下级
		$users=$HousingIndustrymdoel->where('pid',$id)->select()->toArray ();
//判读下级是否存在 则循环处理
		if ($users){
			//循环下级id
			foreach($users as $k=> $v) {
				$users[$k]['stat']=[];
				//递归一个一个查找下级返回数据 存入
				$userss= $this->getTree($v['id']);
				if ($userss){

					foreach($userss as $kk=> $vs) {
						$users[$k]['stat'][$kk] = $vs;
					}
				}
				$result[$k] =$users[$k];
			}
		}
		return $result;
	}








}